#include <bits/stdc++.h>
// 2025/01/27
// tag:
// Author: Zhang Muen
using namespace std;

int64_t n, m, dream[1000001], prefix[1000001];
unordered_map<int64_t, int64_t> um;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> dream[i];
    for (int i = 1; i <= n; i++)
        prefix[i] = prefix[i - 1] ^ dream[i], um[prefix[i]]++;
    um[0]++;
    int64_t ans = 0, maximum = 0, minimum = INT64_MAX, cnt = 0, s = 0;
    for (auto x : um)
        s += x.second * (x.second - 1) / 2;
    for (int i = 1; i <= m; i++) {
        int p, x;
        cin >> p >> x;
        s -= um[prefix[p]] * (um[prefix[p]] - 1) / 2;
        um[prefix[p]]--;
        s += um[prefix[p]] * (um[prefix[p]] - 1) / 2;
        prefix[p] ^= x;
        s -= um[prefix[p]] * (um[prefix[p]] - 1) / 2;
        um[prefix[p]]++;
        s += um[prefix[p]] * (um[prefix[p]] - 1) / 2;
        ans ^= s;
        if (s % 2 == 1)
            cnt++;
        maximum = max(maximum, s), minimum = min(minimum, s);
    }
    cout << ans << endl;
    cout << cnt << endl;
    cout << maximum << endl;
    cout << minimum << endl;
    return 0;
}